package com.itcast.springDemo.controller;

import com.itcast.springDemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/users")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping(value = "/findAll")
    public String findAll() throws Exception {
        System.out.println("接收前端给的参数");
        System.out.println("将参数封装,封装以后传参更方便");
        System.out.println("调用service层,将数据交给service层处理,并且得到结果");
//        UserServiceImpl userService = new UserServiceImpl();
//        String result = userService.findAll();
        String all = userService.findAll();
        System.out.println("将结果返回给前端");
        return all;
    }
    @RequestMapping("/delete")
    public String delete() throws Exception {
        System.out.println("接受前端给的参数");
        System.out.println("将参数封装,封装了以后传参更方便");
        System.out.println("调用service层, 将数据递交给service层处理,并且得到结果");
        String all = userService.findAll();
        System.out.println("将结果响应给前端");
        return all;
    }
}
